/******************************************************************************
*	cmMutex.h	Header file of CM Mutex Module
*
*	coypright (C) 2009 Ding Lixing
*
******************************************************************************/


#ifndef __CMMUTEX_INC__
#define __CMMUTEX_INC__

#ifdef __cplusplus
extern "C" {
#endif

struct cmMutexData_typ {
    cmTASK *owner;
    int nesting;
    unsigned char ceil;
};
typedef struct cmMutexData_typ cmMUTEXDATA;

struct cmMutex_typ {
    cmOBJ obj;
    cmMUTEXDATA data;
};
typedef struct cmMutex_typ cmMUTEX;

extern int cmMutexInit(cmMUTEX * mutex, unsigned int opt, unsigned char ceil);
extern int cmMutexLock(cmMUTEX *mutex, unsigned int tout);
extern int cmMutexUnlock(cmMUTEX *mutex);

#ifdef __cplusplus
}
#endif

#endif /* __CMMUTEX_INC__ */

